package com.cwh.taskcenter.notice.consumer;

import com.cwh.taskcenter.domain.system.event.SmsSendEvent;
import com.cwh.taskcenter.domain.system.domainservice.SmsSendDomainService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author cwh
 */
@Component
@Slf4j
public class MailSendEventConsumer {

    @Resource
    private SmsSendDomainService smsSendDomainService;

    @EventListener
    @Async // Spring Event 默认在 Producer 发送的线程，通过 @Async 实现异步
    public void onMessage(SmsSendEvent message) {
        log.info("[onMessage][消息内容({})]", message);
        smsSendDomainService.doSendSms(message);
    }


}
